assume cs:codesg, ss:stacksg
stacksg segment
               db 400 dup(0)
stacksg ends
codesg segment
       start: mov  ax, 3000h
              mov  ds, ax
              mov  ax, 4000h
              mov  es, ax
              mov  ax, stacksg
              mov  ss, ax
              mov  si, 1500h
              mov  di, 2000h
              mov  bp, 0
              mov  cx, 100
              cld
       s:     repe cmpsb
              jnz  save              ; 比较出不同进行保存
              jz   done              ; 全部相同程序结束
       save:  dec  si                ;保存si
              mov  ss:[bp], si
              add  bp, 2
              inc  si
              dec  di                ;保存di
              mov  ss:[bp], di
              add  bp, 2
              inc  di
              jcxz done              ;全部比完，结束程序
              jmp  s                 ; 还有没比的，继续比较
       done:  mov  ax, 4c00h
              int  21h

codesg ends
end start